package com.anjho.dao;

import java.util.List;

import javax.persistence.Query;

import com.anjho.pojo.Distributor;

public class DAODistributor extends DAOGeneric {

	private static final long serialVersionUID = -602976644471340449L;

	public DAODistributor() {
		super();
	}
	
	@SuppressWarnings("unchecked")
	public List<Distributor> getDistributorList() throws Exception {
		return (List<Distributor>)super.getList("Distributor.getDistributorList");
	}
	
	public Distributor getDistributorByDicode(int dicode){
		Query query = entityManager.createNamedQuery("Distributor.getDistributorByDicode");
		query.setParameter("dicode", dicode);
		Distributor distributor = null;
		try {
			distributor = (Distributor)query.getSingleResult();
		} catch (Exception e){
			//TODO: TRATAMENTO DE ERROS
			e.printStackTrace();
		}
		return distributor;
	}

}
